Overview

This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:

datatable(cryptodata, rownames = FALSE, 
          options(list(lengthMenu = c(4, 5, 6))))

Price Chart

Interactive Chart

Python Code Example

import pandas as pd
# Show the R data from Python
r.cryptodata
##         pair symbol  ask_1_price       date_time_utc
## 0     ETHUSD    ETH      591.306 2020-12-08 00:00:01
## 1     ETHUSD    ETH      590.409 2020-12-08 01:00:01
## 2     ETHUSD    ETH      589.191 2020-12-08 02:00:01
## 3     ETHUSD    ETH      589.218 2020-12-08 03:00:01
## 4     ETHUSD    ETH      588.182 2020-12-08 04:00:01
## ...      ...    ...          ...                 ...
## 2015  ETHUSD    ETH      355.851 2020-09-09 20:00:38
## 2016  ETHUSD    ETH      352.805 2020-09-09 21:00:39
## 2017  ETHUSD    ETH      352.934 2020-09-09 22:00:39
## 2018  ETHUSD    ETH      355.471 2020-09-09 23:00:38
## 2019  ETHUSD    ETH      357.844                 NaT
## 
## [2020 rows x 4 columns]

One more Python example

Press on w on your keyboard to make the presentation wider. Press f to fullscreen.

import numpy as np
# Create a new field based on the price value:
df['price_percentile'] = np.where(df['ask_1_price'] > np.percentile(df['ask_1_price'], 50),
                            'upper 50th percentile of prices', 
                            'lower 50th percentile of prices')
# Show modified dataframe:
df[['symbol', 'ask_1_price', 'price_percentile']]
##      symbol  ask_1_price                 price_percentile
## 0       ETH      591.306  upper 50th percentile of prices
## 1       ETH      590.409  upper 50th percentile of prices
## 2       ETH      589.191  upper 50th percentile of prices
## 3       ETH      589.218  upper 50th percentile of prices
## 4       ETH      588.182  upper 50th percentile of prices
## ...     ...          ...                              ...
## 2015    ETH      355.851  lower 50th percentile of prices
## 2016    ETH      352.805  lower 50th percentile of prices
## 2017    ETH      352.934  lower 50th percentile of prices
## 2018    ETH      355.471  lower 50th percentile of prices
## 2019    ETH      357.844  lower 50th percentile of prices
## 
## [2020 rows x 3 columns]